﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Douban.Api.Infrastructure;
using Douban.Api.User;

namespace Douban.Api.Broadcast
{
    [Entry]
    public class Miniblog : EntryItem
    {
        private string _category;

        [Element("author")]
        public Author Author { get; set; }

        [Element("id")]
        public string Id { get; set; }

        [Element("title")]
        public string Content { get; set; }

        [Element("content")]
        public string HtmlContent { get; set; }

        [Element("published")]
        public DateTime PublishedTime { get; set; }

        [AttributeElement("comments_count")]
        public int CommentsCount { get; set; }

        [Category]
        public string Category
        {
            get
            {
                return _category;
            }
            set 
            {
                if (value != null)
                {
                    int index = value.LastIndexOf('.');
                    _category = value.Substring(index + 1);
                }
            }
        }
    }
}
